<template>
    <div>
        <el-button style="margin-right:20px;margin-bottom: 10px" @click="toPurchaseOrder">返 回</el-button>
        <el-form>
            <el-form-item style="background: #e1e1e1">
                <span style="color: #3A3A3A;margin-left:10px">订单信息</span>

            </el-form-item>
            <el-form-item style="border-bottom:1px solid #ebeef5;" label-width="0px">
                <div v-if="detaildata.purchasetype===1">
                    <span style="color: #3A3A3A;margin-left:20px">积分支付</span>
                </div>
                <div v-if="detaildata.purchasetype===0">
                    <span style="color: #3A3A3A;margin-left:20px">余额支付</span>
                </div>
            </el-form-item>
            <el-form-item style="border-bottom:1px solid #ebeef5;" label-width="0px">

                <el-form-item label="创建时间：" style="width:30%;display: inline-block;margin-left:20px">
                        <span style="color: #3A3A3A"
                              v-if="detaildata.createtime!=null">{{ detaildata.createtime | formatDateStr('yyyy-MM-dd hh:mm:ss') }}</span>
                </el-form-item>
                <el-form-item label="付款时间：" style="margin-left:80px; width:30%;display: inline-block;">

                    <i class="el-icon-time" v-if="detaildata.paytime!=null"></i>
                    <span style="color: #3A3A3A"
                          v-if="detaildata.paytime!=null"
                    >{{ detaildata.paytime | formatDateStr('yyyy-MM-dd hh:mm:ss') }}</span>

                </el-form-item>
            </el-form-item>

            <el-form-item style="border-bottom:1px solid #ebeef5;" label-width="0px">

                <el-form-item label="发货时间：" style="width:30%;display: inline-block;margin-left:20px">
                    <div v-if="detaildata.delivergoodstime!=null">
                            <span style="color: #3A3A3A"
                            >{{detaildata.delivergoodstime | formatDateStr('yyyy-MM-dd hh:mm:ss') }}</span>
                    </div>
                    <div v-else >
                        <span>无</span>
                    </div>

                </el-form-item>
                <el-form-item label="完成时间：" style="margin-left:80px; width:30%;display: inline-block; ">


                    <div v-if="detaildata.completiontime!=null">
                             <span  style="color: #3A3A3A"
                             >{{detaildata.completiontime | formatDateStr('yyyy-MM-dd hh:mm:ss') }}</span>
                    </div>
                    <div v-else >
                        <span>无</span>
                    </div>


                </el-form-item>
            </el-form-item>

            <el-form-item style="border-bottom:1px solid #ebeef5;" label-width="0px">

                <el-form-item label="订单编号：" style="width:30%;display: inline-block;margin-left:20px">
                    <span style="color: #3A3A3A"> {{detaildata.ordernumber}}</span>
                </el-form-item>
                <el-form-item label="开具发票：" style="margin-left:80px; width:30%;display: inline-block; ">

                    <div style="display: inline-block" v-if="detaildata.isopeninginvoice===1">
                        <span style="color: #3A3A3A;margin-right: 20px;">需要</span>

                        <div style="display: inline-block">
                            <el-button type="primary" @click.native="invoiceclick()">查看发票信息</el-button>
                        </div>
                    </div>
                    <div style="display: inline-block" v-else>
                        <span style="color: #3A3A3A;margin-right: 20px;">不需要</span>
                    </div>

                </el-form-item>
            </el-form-item>
        </el-form>

        <!--列表start --222s-->
        <el-table
            ref="multipleTable"
            v-loading="loading"
            :data="detaildata.sdlist"
            :header-cell-style="{background:'#F4F4F5',color:'#606266'}"
            border
        >
            <!--<el-table-column type="selection" width="50" fixed/>-->
            <el-table-column label="商品ID" prop="commodityid" width="50" align="center"/>
            <el-table-column label="图片" prop="commodityicon" width="150" align="center">
                <template slot-scope="scope">
                    <el-popover v-if="scope.row.commodityicon" placement="right" trigger="hover">
                        <img :src="scope.row.commodityicon" style="width:400px;border-radius:3px;">
                        <img
                            slot="reference"
                            :src="scope.row.commodityicon"
                            style="max-height: 80px;max-width: 50px;border-radius:5px;"
                        >
                    </el-popover>
                    <span v-else>-</span>
                </template>
            </el-table-column>
            <el-table-column label="商品名称" prop="commodityname" width="200" align="center"/>
            <el-table-column label="单价（元）" prop="price" width="200" align="center"/>
            <el-table-column label="数量" prop="purchasenum" width="200" align="center"/>
            <el-table-column label="规格" prop="inventory" width="200" align="center"/>
            <el-table-column label="快递" prop="expressname" width="200" align="center"/>
            <el-table-column label="合计（元）" prop="totalprice" align="center"/>
            <el-table-column label="物流信息" align="center">
                <template slot-scope="scope">
                    <div v-if="scope.row.secondorderstatus!==0">
                        <el-button type="primary" size="mini" @click.native="handleForm(scope.$index,scope.row)">查看
                        </el-button>
                    </div>

                </template>
            </el-table-column>
        </el-table>

        <!---->
        <el-form>
            <el-form-item style="border-bottom:1px solid #ebeef5;" label-width="0px">

                <el-form-item label="订单状态：" >
                    <div v-if="detaildata.orderstatus===0">
                        <span style="color: #3A3A3A">待付款</span>
                    </div>
                    <div v-if="detaildata.orderstatus===1">
                        <span style="color: #3A3A3A">待发货</span>
                    </div>
                    <div v-if="detaildata.orderstatus===2">
                        <span style="color: #3A3A3A"> 待收货</span>
                    </div>
                    <div v-if="detaildata.orderstatus===3">
                        <span style="color: #3A3A3A">已完成</span>
                    </div>
                    <div v-if="detaildata.orderstatus===4">
                        <span style="color: #3A3A3A">已关闭</span>
                    </div>
                    <div v-if="detaildata.orderstatus===5">
                        <span style="color: #3A3A3A">已取消</span>
                    </div>

                </el-form-item>
            </el-form-item>


            <el-form-item style="border-bottom:1px solid #ebeef5;" label-width="0px">

                <el-form-item label="运费（元）：" style="width:30%;display: inline-block;margin-left:20px">
                    <span style="color: #3A3A3A">{{detaildata.postage}}</span>
                </el-form-item>
                <el-form-item v-if="detaildata.orderstatus !==6" label="实付金额（元）：" style="margin-left:80px; width:50%;display: inline-block;">
                    <div>
                        <span style="color: #3A3A3A">{{detaildata.orderrealprice}}</span>
                    </div>

                </el-form-item>
            </el-form-item>

        </el-form>
        <!---->
        <!--卖家-->
        <el-form>
            <el-form-item style="background: #e1e1e1">
                <span style="color: #3A3A3A">买家信息</span>
            </el-form-item>
            <el-form-item style="border-bottom:1px solid #ebeef5;" label-width="0px">

                <el-form-item label="用户昵称：" style="width:30%;display: inline-block;margin-left:20px">
                    <span style="color: #3A3A3A">{{detaildata.usernick}}</span>
                </el-form-item>
                <el-form-item label="取货方式：" style="margin-left:80px; width:30%;display: inline-block;">
                    <div v-if="detaildata.pickuptype==0">
                        <span style="color: #3A3A3A">商家配送</span>
                    </div>
                    <div v-if="detaildata.pickuptype==1">
                        <span style="color: #3A3A3A"> 商家配送</span>
                    </div>
                </el-form-item>
            </el-form-item>
            <el-form-item style="border-bottom:1px solid #ebeef5;" label-width="0px">

                <el-form-item label="收货人：" style="width:30%;display: inline-block;margin-left:20px">
                    <span style="color: #3A3A3A">{{detaildata.useraddressname}}</span>
                </el-form-item>
                <el-form-item label="联系方式：" style="margin-left:80px; width:30%;display: inline-block;">
                    <span style="color: #3A3A3A">{{detaildata.useraddressphone}}</span>
                </el-form-item>
            </el-form-item>

            <el-form-item>
                <el-form-item label="收货地址：" style="width:30%;display: inline-block;margin-left:20px">
                    <div v-if="detaildata.province">
                        <span style="color: #3A3A3A">{{detaildata.province+" "+detaildata.city+" "+detaildata.area+" "+detaildata.useraddress}}</span>
                    </div>
                    <div v-else>
                        <span style="color: #3A3A3A">{{detaildata.useraddress}}</span>
                    </div>

                </el-form-item>
            </el-form-item>
            <el-form-item>
                <el-form-item label="买家留言：" style="width:30%;display: inline-block;margin-left:20px">
                    <span style="color: #3A3A3A">{{detaildata.buyermessage}}</span>
                </el-form-item>
            </el-form-item>

        </el-form>
        <!--发票orderinvoice-->
        <el-dialog
            title="查看发票"
            :visible.sync="invoiceVisible"
            width="1000px"
            top="5vh"
            v-dialogDrag
        >
            <el-form v-if="detaildata.orderinvoice!=null" label-width="140px">

                <el-form-item style="border-bottom:1px solid #ebeef5;" label-width="0px">

                    <el-form-item label="发票类型:" style="width:30%;display: inline-block;">

                        <div v-if="detaildata.orderinvoice.invoicetype===0">
                            <span>普通</span>
                        </div>
                        <div v-if="detaildata.orderinvoice.invoicetype===1">
                            <span>专用</span>
                        </div>

                    </el-form-item>
                    <el-form-item label="抬头公司:" style="margin-left:80px; width:30%;display: inline-block;">

                        <div v-if="detaildata.orderinvoice.rrisetype===0">
                            <span>个人</span>
                        </div>
                        <div v-if="detaildata.orderinvoice.rrisetype===1">
                            <span>公司</span>
                        </div>
                    </el-form-item>

                </el-form-item>

                <el-form-item style="border-bottom:1px solid #ebeef5;" label-width="0px">

                    <el-form-item label="发票抬头:" style="width:30%;display: inline-block;">
                        <div>
                            <span>{{detaildata.orderinvoice.invoicerrise}}</span>
                        </div>
                    </el-form-item>
                    <el-form-item label="税号:" style="margin-left:80px; width:30%;display: inline-block;">
                        <div>
                            <span>{{detaildata.orderinvoice.dutyparagraph}}</span>
                        </div>
                    </el-form-item>

                </el-form-item>

                <el-form-item style="border-bottom:1px solid #ebeef5;" label-width="0px">
                    <el-form-item label="开户行:" style="width:30%;display: inline-block;">
                        <div>
                            <span>{{detaildata.orderinvoice.openingbank}}</span>
                        </div>
                    </el-form-item>
                    <el-form-item label="银行卡号:" style="margin-left:80px; width:30%;display: inline-block;">
                        <div>
                            <span>{{detaildata.orderinvoice.bankcardnumber}}</span>
                        </div>
                    </el-form-item>

                </el-form-item>

                <el-form-item style="border-bottom:1px solid #ebeef5;" label-width="0px">

                    <el-form-item label="联系手机:" style="width:30%;display: inline-block;">
                        <div>
                            <span>{{detaildata.orderinvoice.userphone}}</span>
                        </div>
                    </el-form-item>
                    <el-form-item label="联系邮箱:" style="margin-left:80px; width:30%;display: inline-block;">
                        <div>
                            <span>{{detaildata.orderinvoice.useremail}}</span>
                        </div>
                    </el-form-item>
                    <el-form-item>
                        <div>
                            <span>{{detaildata.orderinvoice.remarks}}</span>
                        </div>
                    </el-form-item>

                </el-form-item>

            </el-form>

        </el-dialog>

     <el-dialog
            title="物流信息"
            :visible.sync="dialoglook"
            width="50%"
            :close-on-click-modal="false"
        >
           <el-form label-width="100px" style="margin-left: 50px;">
                
                <!-- <img src="trailUrl" alt="地图展示有问题，请稍后重试"> -->
                <div v-if="logisticsdata.status==200">
                    <div style="margin-bottom: 20px;">
                        <div>
                            <span style="font-size:16px;font-weight:bold">承运快递:</span>
                            <span style="display: inline-block;margin-left: 20px;">{{logisticsdata.comname}}</span>
                        </div>
                        <div style="margin-top: 10px;">
                            <span style="font-size:16px;font-weight:bold">快递单号:</span>
                            <span style="display: inline-block;margin-left: 20px;">{{logisticsdata.nu}}</span>
                        </div>
                    </div>

                    <el-table
                        ref="multipleTable"
                        v-loading="loading"
                        :data="logisticsdata.data"
                        :header-cell-style="{background:'#F4F4F5',color:'#606266'}"
                        :row-class-name="tableRowClassName"
                        border
                    >
                    <el-table-column label="状态" prop="status" width="70" align="center">
                        <template slot-scope="scope">
                        <div slot="reference" class="name-wrapper" >
                                <el-tag size="medium">{{ scope.row.status}}</el-tag>
                        </div>  
                        </template>
                    </el-table-column>
                    <el-table-column label="时间" prop="time" width="200" align="center">
                        <template slot-scope="scope">
                            <i class="el-icon-time"></i>
                            <span style="margin-left: 10px">{{ scope.row.time }}</span>
                        </template>
                    </el-table-column>
                    <el-table-column label="物流信息" prop="context" ></el-table-column>
                </el-table>
                </div>
                <div v-if="logisticsdata.Success===false">
                    <ul>
                        <li>
                            <span>{{logisticsdata.Reason}}</span>
                        </li>
                    </ul>
                </div>
                <div v-if="logisticsdata.status==null">
                   <ul>
                       <li>
                            <span style="color:red;font-size:16px;font-weight:bold;margin-left:20px"> 1.请核对物流单号</span>
                        </li>
                        <li>
                            <span style="color:red;font-size:16px;font-weight:bold;margin-left:20px">2.{{logisticsdata.message}}</span>
                        </li>
                    </ul>
                </div>
            </el-form>
             <span slot="footer" class="dialog-footer">
                <el-button @click="dialoglook = false">返回</el-button>
             </span>
        </el-dialog>
        <!--修改价格-->
        <el-dialog
            title="修改价格"
            :visible.sync="dialogEdit"
            width="30%"
        >
            <el-form :model="fjson" :rules="rules" ref="ruleForm" label-width="100px">
                <el-form-item label="支付价格" prop="orderrealprice">
                    <el-input v-model="fjson.orderrealprice"></el-input>

                </el-form-item>
            </el-form>
            <span slot="footer" class="dialog-footer">
       <el-button @click="dialogEdit = false">取 消</el-button>
       <el-button type="primary" :loading="formSumbitLoding" @click="formSumbit">提交</el-button>
       </span>
        </el-dialog>
        <!--快递-->
        <el-dialog
            title="物流信息"
            :visible.sync="dialogSend"
            width="50%"
        >
            <el-form label-width="100px" style="margin-left: 50px;">
                <el-form-item class="query-form-item" label="快递单号">
                    <el-input
                        v-model="expressnumber"
                        placeholder="请输入快递单号"
                        prefix-icon="el-icon-search"
                        @keyup.enter.native="searchcompany"
                        clearable
                    ></el-input>
                </el-form-item>

                <div >
                    <!--查询条件start --111s-->
                    <el-form :inline="true"  class="query-form" size="small"  @submit.native.prevent>

                        <el-form-item class="query-form-item" label="快递公司名称">
                            <el-input
                                v-model="query.company"
                                placeholder="请输入快递公司"
                                prefix-icon="el-icon-search"
                                @keyup.enter.native="searchcompany"
                                clearable
                            ></el-input>
                        </el-form-item>
                        <el-form-item>
                            <el-button type="primary" icon="el-icon-refresh" @click="oncompanyRest"></el-button>
                            <el-button type="primary" icon="el-icon-search" @click="searchcompany">查询</el-button>
                        </el-form-item>

                    </el-form>
                    <!--查询条件end-->

                    <!--列表start --222s-->
                    <el-table
                        ref="multipleTable"
                        v-loading="loading"
                        :data="expresscompanylist"
                        :header-cell-style="{background:'#F4F4F5',color:'#606266'}"
                        @selection-change="handleSelectionChange"
                        border
                    >
                        <el-table-column type="selection" width="50" fixed/>
                        <el-table-column label="快递公司编码ID" prop="code" width="200" align="center"/>
                        <el-table-column label="快递公司" prop="company" align="center"/>

                    </el-table>
                    <!--列表end --222e-->

                    <!--分页模块start-->
                    <el-pagination
                        class="pagination-container"
                        background
                        :page-size="query.pageSize"
                        @size-change="handleSizeChange"
                        @current-change="handleCurrentChange"
                        layout="total,sizes,prev, pager, next, jumper"
                        :current-page="query.currentPage"
                        :page-sizes="[10, 20, 30, 50]"
                        :total="totalNumber"
                    ></el-pagination>
                    <!--分页模块end-->

                    <!---->
                </div>

            </el-form>
            <span slot="footer" class="dialog-footer">
                   <el-button type="danger" size="small" @click="submityinfo()" >提交</el-button>
            <el-button @click="back" size="small">返回</el-button>
            </span>
        </el-dialog>
    </div>
</template>
<script>
import {
    getCommodityOrderDetail,
    getlogistics,
    updateOrder,
    getLogisticsCompany,
    updateOrderStatus
} from "../../api/statistics/statistics.js";
import Tinymce from "../../components/Tinymce/index.vue";
/*用作表单的数据初始化*/
const formJson = {
    commodityid: "" //商品id
};
const Json = {
    orderrealprice: "" //支付价格
};
export default {
    components: {
        Tinymce
    },
    data() {
        return {
            orderid: "", //订单id
            formData: formJson, //新增或修改的对象
            fjson: Json, //
            dialogEdit: false, //修改价格
            formSumbitLoding: false, //提交
            orderrealprice: "", //支付价格
            createTime: [], //选择日期时需要的model
            sendtime: "",
            taketime: "",

            list: [], //二级列表
            detaildata: {}, //详细
            logisticsdata: {}, //快递信息
            dialoglook: false, //物流
            dialogSend: false, //发货
            invoiceVisible: false, //发票
            formVisible: false, //添加编辑显示
            loading: false, //列表加载
            formLoading: false, //表单提交加载

            expresscompanylist: [], //快递公司列表
            secondorderid: "", //二级订单号码
            expressnumber: "", //物流单号
            company: "", //快递公司
            totalNumber: 0, //分页总页数
            query: {
                //查询条件
                company: "",
                currentPage: 1,
                pageSize: 10
            },

            multipleSelection: [], //多选集合
            rules: {
                //表单校验
                orderrealprice: {
                    required: true,
                    message: "请输入价格",
                    trigger: "blur"
                }
            }
        };
    },

    methods: {
        tableRowClassName({ row, rowIndex }) {
            // console.log(row);
            // console.log(rowIndex);
            if (rowIndex === 1) {
                return "warning-row";
            } else if (rowIndex === 3) {
                return "success-row";
            } else if (rowIndex === 10) {
                return "success-row";
            }
            return "";
        },
        back() {
            this.oncompanyRest();
            this.dialogSend = false;
        },

        toPurchaseOrder() {
            this.$router.push({
                path: "/merchantOrder/purchaseOrder",
                query: {}
            });
        },
        /*修改价格*/
        modifyprice() {
            if (this.orderid != "") {
                this.dialogEdit = true;
            }
        },
        /*提交事件*/
        formSumbit() {
            //表单校验通过
            //alert("123")
            this.$refs["ruleForm"].validate(valid => {
                if (valid) {
                    this.formSumbitLoding = true;
                    var params = new URLSearchParams();
                    params.append("orderid", this.orderid);
                    params.append("orderrealprice", this.fjson.orderrealprice);
                    updateOrder(params)
                        .then(response => {
                            this.formLoading = false;
                            if (response.code != 0) {
                                this.$message.error(response.message);
                                this.formSumbitLoding = false;
                                return false;
                            }
                            this.$message.success("操作成功");

                            this.formSumbitLoding = false;
                            this.dialogEdit = false;
                            // 加载表格数据
                            this.getList();
                            // 清空表单
                            this.$refs["dataForm"].resetFields();
                        })
                        .catch(() => {
                            this.formSumbitLoding = false;
                            this.dialogEdit = false;
                        });
                }
            });
            //new URLSearchParams(this.query)  提交数据格式不正确时可以转一下
        },
        oncompanyRest() {
            this.query = {
                company: "",
                currentPage: 1,
                pageSize: 10
            };
            this.getinfo();
        },

        searchcompany() {
            this.query.currentPage = 1;
            this.getinfo();
        },
        /*列表复选框选择事件*/
        handleSelectionChange(val) {
            this.multipleSelection = val;
            if (val == "") {
                this.cancelToggle = false;
                return;
            }
            this.cancelToggle = true;
        },
        /*全选删除事件*/
        submityinfo() {
            if (this.multipleSelection.length > 1) {
                this.$message({
                    message: "请先选择一个快递",
                    type: "warning"
                });
                return;
            }
            var expresscode = this.multipleSelection
                .map(item => item.code)
                .join(); //获取所有选中行的id组成的字符串，以逗号分隔
            var expressname = this.multipleSelection
                .map(item => item.company)
                .join(); //获取所有选中行的id组成的字符串，以逗号分隔
            if (expresscode == "") {
                this.$message({
                    message: "请先选择",
                    type: "warning"
                });
                return;
            }
            this.updateinfo(
                this.secondorderid,
                this.expressnumber,
                expresscode,
                expressname
            );
        },
        //更新订单状态
        updateinfo(secondorderid, expressnumber, expresscode, expressname) {
            var params = new URLSearchParams();
            params.append("secondorderid", secondorderid);
            params.append("expressname", expressname);
            params.append("expresscode", expresscode);
            params.append("expressnumber", expressnumber);
            updateOrderStatus(params)
                .then(response => {
                    if (response.code) {
                        this.$message.error(response.message);
                        this.dialogSend = false;
                        return;
                    }
                    this.$message.success("发货成功"); //+response.message
                    this.dialogSend = false;
                    this.getList();
                    setTimeout(() => {
                        this.loading = false;
                        this.dialogSend = false;
                    }, 0.3 * 1000);
                })
                .catch(() => {
                    this.dialogSend = false;
                    this.totalNumber = 0;
                });
        },

        /*点击页数*/
        handleCurrentChange(val) {
            this.query.currentPage = val;
            this.getinfo();
        },

        /*选择每页条数【10,20,30,40,50】*/
        handleSizeChange(val) {
            this.query.pageSize = val;
            this.getList();
        },
        //查看物流
        handleForm(index, row) {
            console.log(row);
            // com  快递公司编码 expresscode
            // num  运单号       expressnumber
            // from 发货地址
            // to      收货地址（省、市、区）其他默认 cityName
            if (row.expresscode == undefined || row.expresscode == null) {
                this.$message.warning("没有物流单号");
                return;
            }
            if (row.expressnumber == undefined || row.expressnumber == null) {
                this.$message.warning("没有物流单号");
                return;
            }
            let data = {
                com: row.expresscode,
                num: row.expressnumber,
                to: this.detaildata.city
            };

            getlogistics(data)
                .then(response => {
                    if (response.code) {
                        this.$message.error(response.message);
                        return;
                    }
                    // console.log(response.data)
                    let expressname = {};
                    expressname.comname = row.expressname;
                    this.logisticsdata = Object.assign(
                        {},
                        expressname,
                        response.data
                    );
                    console.log(this.logisticsdata);
                    this.trailUrl = response.data.trailUrl;
                })
                .catch(() => {});
            this.dialoglook = true;
        },

        //查看发票信息
        invoiceclick() {
            this.invoiceVisible = true;
        },
        //显示发货列表
        showSend(index, row) {
            if (index != undefined) {
                this.dialogSend = true;
                //  alert(row.secondorderid);
                this.secondorderid = row.secondorderid;
                this.getinfo();
            }
        },
        getinfo() {
            //alert("发货")
            this.loading = true;

            var params = new URLSearchParams(this.query);
            //params.append("company", this.company);
            getLogisticsCompany(params)
                .then(response => {
                    if (response.code != 0) {
                        this.$message.error(response.message);
                        this.loading = false;
                        return false;
                    }
                    this.loading = false;

                    // console.info("999"+response.data.sdlist)
                    this.expresscompanylist = response.data.list;
                    this.totalNumber = response.data.totalNumber || 0;

                    if (response.data.sdlist != null) {
                        this.sendtime = response.data.sdlist[0].taketime;
                        this.taketime = response.data.sdlist[0].sendtime;
                    }

                    //console.info(this.detaildata)
                })
                .catch(() => {
                    this.loading = false;
                    this.list = [];
                });
        },

        //发货
        handleSend(index, row) {
            this.loading = true;
            var params = new URLSearchParams();
            params.append("expresscode", row.expresscode);
            params.append("expressname", row.expressnumber);
            params.append("secondorderid", row.expressnumber);
            params.append("expressnumber", row.expressnumber);
            getlogistics(params)
                .then(response => {
                    if (response.code) {
                        this.$message.error(response.message);
                        this.loading = false;
                        return;
                    }

                    ///  this.logisticsdata=JSON.stringify(response.data);//仓库
                    this.logisticsdata = JSON.parse(response.data);
                    // console.info(this.logisticsdata)
                    setTimeout(() => {
                        this.loading = false;
                    }, 0.3 * 1000);
                })
                .catch(() => {
                    this.loading = false;
                    this.list = [];
                    this.totalNumber = 0;
                });
        },

        //显示 查看弹框

        detailForm(index, row) {
            if (row !== null) {
                this.detailVisible = true;
                this.formData = Object.assign({}, row);
                this.formName = "detail";
            }
        },

        // 隐藏详情弹框
        hideDetailForm() {
            // 更改值
            this.detailVisible = !this.detailVisible;
            return true;
        },

        /*获取列表事件*/
        getList() {
            this.loading = true;
            var params = new URLSearchParams();
            params.append("orderid", this.orderid);
            getCommodityOrderDetail(params)
                .then(response => {
                    if (response.code != 0) {
                        this.$message.error(response.message);
                        this.loading = false;
                        return false;
                    }
                    // console.info("999"+response.data.sdlist)
                    this.detaildata = response.data;
                    if (response.data != null && response.data.sdlist != null) {
                        this.sendtime = response.data.sdlist[0].taketime;
                        this.taketime = response.data.sdlist[0].sendtime;
                    }
                    this.loading = false;
                    //console.info(this.detaildata)
                })
                .catch(() => {
                    this.loading = false;
                    this.list = [];
                });
        },

        /*刷新*/
        onRest() {
            this.$router.push({
                path: ""
            });
            //刷新事件需要重置查询条件
            this.createTime = [];
            this.query = {
                currentPage: 1,
                pageSize: 10
            };
            this.getList();
        }
    },
    mounted() {
        this.orderid = this.$route.query.orderid;
    },
    created() {
        this.orderid = this.$route.query.orderid;

        this.getList();
    }
};
</script>
<style type="text/css">
.el-table .warning-row {
    background: oldlace;
}

.el-table .success-row {
    background: #f0f9eb;
}
</style>
